import pandas as pd
import requests

target_url = 'http://127.0.0.1:3000/book-info/'

if __name__ == '__main__':
    excel_path = r"C:\Users\masaikk\Desktop\文天祥研究古籍及民国文献平台建设（数据）0416.xlsx"
    raw_data = pd.read_excel(excel_path)
    raw_data.columns = ['dynasty', 'yearTitle', 'bookName', 'author', 'totalVolume', 'volumeName', 'volume', 'context',
                        'page']
    for i in range(raw_data.size):
        try:
            a_row_data = raw_data.iloc[i]
            dict_data = a_row_data.to_dict()
            print(dict_data)
            requests.post(target_url, data=dict_data)
        except:
            continue
